home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / The Hacks! / Interim Executive Decision / Outline Table Demo / sources / CEditTable.cp < prev    next >
Encoding:
Text File  |  1998-06-21  |  1.7 KB  |  76 lines  |  [TEXT/CWIE]

  1. //========================================================================
  2. // CEditTable.cp        ©1997 Metrowerks, Inc. All rights reserved
  3. // Original author: John C. Daub
  4. //========================================================================
  5. // An outline table that demonstrates pane hosting and in-place editing
  6.  
  7.  
  8. #include "CEditTable.h"
  9.  
  10. #include <LTablePaneHostingGeometry.h>
  11. #include <LOutlineKeySelector.h>
  12. #include <LOutlineRowSelector.h>
  13. #include <UAttachments.h>
  14.  
  15. #include "CEditItem.h"
  16.  
  17. #include "OutlineTablePrefix.h"
  18.  
  19.  
  20.  
  21. CEditTable::CEditTable(
  22.     LStream *inStream )
  23.         : LOutlineTable( inStream )
  24. {
  25.     SetTableGeometry( new LTablePaneHostingGeometry( this, kColWidth, 20 ) );
  26.     
  27.     // set the table selector
  28.     
  29.     SetTableSelector(new LOutlineRowSelector( this ) );
  30.     
  31.     // and note that we don't set the table storage.... 
  32.     
  33.     // most of the table classes not only maintain the graphical
  34.     // representation of your data but also the data itself. But
  35.     // LOutlineTable doesn't really do this...it mostly handles
  36.     // graphical representation... you need to handle your data
  37.     // maintenance elsewhere by yourself.
  38.     
  39.     // insert a couple columns (name and size)
  40.     
  41.     InsertCols( 1, 0, nil, nil, false );
  42.  
  43.     // Set up keyboard selection and scrolling.
  44.  
  45.     AddAttachment(new LOutlineKeySelector(this, msg_AnyMessage));
  46.     AddAttachment(new LKeyScrollAttachment(this));
  47.  
  48.     // Try to become default commander in the window.
  49.  
  50.     if (mSuperCommander != nil) {
  51.         mSuperCommander->SetLatentSub(this);
  52.     }    
  53. }
  54.  
  55.  
  56.  
  57. CEditTable::~CEditTable()
  58. {
  59.     // nothing
  60. }
  61.  
  62.  
  63. void
  64. CEditTable::FinishCreateSelf()
  65. {
  66.  
  67.     CEditItem *theItem;
  68.     
  69.     for ( Int16 i = 1; i <= 5; ++i ) {
  70.     
  71.         theItem = new CEditItem;
  72.         ThrowIfNil_(theItem);
  73.         
  74.         InsertItem( theItem, nil, nil );
  75.     }
  76. }